//
// Created by hjie on 23-8-6.
//

#pragma once

#include "./../stun_message.h"
#include "./../../loop_event/loop_event_define.h"
#include <functional>
#include <vector>

class TurnServer;
class TurnDataManager;
class StunServerManager;
class StunUdpServer;

using StunMessageFunc = std::function<void(StunMessage&,std::vector<StunMessage>&stun_message_vec)>;

class MessageProcess
{
public:
    explicit MessageProcess(TurnServer * server);
public:
    void ProcessRequest(StunMessage & message, std::vector<StunMessage> & stun_message_vec);
    void ProcessAllocate(StunMessage & message, std::vector<StunMessage> & stun_message_vec);
    void ProcessRefreshRequest(StunMessage & message, std::vector<StunMessage> & stun_message_vec);
    void ProcessCreatePermissionReq(StunMessage & message, std::vector<StunMessage> & stun_message_vec);
    void ProcessSendIndication(StunMessage & message, std::vector<StunMessage> & stun_message_vec);
public:
    void RegisterFunction();
    void CheckUdpServerExpire();
    void ProcessMsgFromUdpServer(StunUdpServer * server, StunMessage & message);
    void ProcessCommand(StunMessage & message, std::vector<StunMessage> & stun_message_vec);
public:
    TurnServer * m_stun_server;
    LoopEvent  * m_loop_event;
private:
    std::shared_ptr<TurnDataManager> m_turn_data_manager;
    std::shared_ptr<StunServerManager> m_stun_server_manager;
private:
    std::map<EmStunMsgType, StunMessageFunc> m_stun_message_func_map;
private:
    
};
